<?php namespace app\common\controller;


class Param{

    public static function parsewhere($filter,$op)
    {
        $w = [];
        if(!empty($filter) && !empty($op)){
            $filter = json_decode($filter,true);
            $op = json_decode($op,true);
            foreach($filter as $k => $v){
                if(isset($op[$k]) && !empty($op[$k])){
                    switch ($op[$k]){
                        case '=':
                            $w[] = [$k,'=',$v];
                            break;
                        case 'like':
                            $w[] = [$k,'like',$v];
                            break;
                        case 'between' :
                            $tmp = explode(',',$v);
                            if(count($tmp) == 2){
                                $w[] = [$k,'between',[$tmp[0],$tmp[1]]];
                                //$w[$k] = ['between',[$tmp[0],$tmp[1]]];
                            }
                            break;
                        default:
                        //$w[$k] = [$op[$k],$v];
                        $w[] = [$k,$op[$k],$v];
                    }
                }
            }
        }

        return $w;
	
    }
    
}
    

?>